package com.itany.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itany.dao.UserDao;
import com.itany.entity.User;
import com.itany.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Author:yaozhiyuan0117@163.com
 * Time:2019/12/20 19:44
 * Describe:
 * version:1.0
 */

@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public PageInfo<User> findByPage(Integer page, Integer rows) {
        PageHelper.startPage(page, rows);
        List<User> users = userDao.selectByPage();
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        return userPageInfo;
    }
}
